package com.jiazhong.example.project.bookstore.front.controller;

import com.jiazhong.example.project.bookstore.commons.bean.Logistics;
import com.jiazhong.example.project.bookstore.commons.util.JsonResult;
import com.jiazhong.example.project.bookstore.front.service.LogisticsService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/logistics")
public class LogisticsController {
    @Resource
    private LogisticsService logisticsService;


    @GetMapping("/find_by_id")
    public JsonResult find(HttpServletRequest request) {
        return logisticsService.findLogisticsByUserId(request.getHeader("token"));
    }

    @PostMapping
    public JsonResult saveLogistics(Logistics logistics, HttpServletRequest request) {
        return logisticsService.saveLogistics(logistics, request.getHeader("token"));
    }
}
